package cn.lijiajia3515.cairo.system.modules.area;

import cn.lijiajia3515.cairo.mongo.data.AbstractMongo;
import cn.lijiajia3515.cairo.system.modules.dictionary.DictionaryMongo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.io.Serializable;
import java.util.List;

/**
 * 区域  mongo
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)

@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder(toBuilder = true)
public class AreaMongo extends AbstractMongo implements Serializable {
	@MongoId
	private ObjectId _id;
	/**
	 * 标识
	 */
	private String id;
	/**
	 * 父级 标识
	 */
	private String parent;
	/**
	 * 层级
	 */
	private Integer level;
	/**
	 * 名称
	 */
	private String name;
	/**
	 * 繁体
	 */
	private String traditional;
	/**
	 * 简称
	 */
	private String abbr;
	/**
	 * 拼音
	 */
	private String pinyin;
	/**
	 * 邮政编码
	 */
	private String zip;
	/**
	 * 祖先节点
	 */
	private List<String> ids;
	/**
	 * 祖先节点名称
	 */
	private List<String> names;

	public static final Field FIELD = new Field();

	public static class Field extends AbstractMongo.Field {
		public final String ID = field("Id");
		public final String PARENT = field("Parent");
		public final String LEVEL = field("Level");
		public final String Name = field("Name");
		public final Array IDS = new Array(this, "Ids");
		public final Array NAMES = new Array(this, "Names");
		public final DictionaryMongo.Field.Items ITEMS = new DictionaryMongo.Field.Items(this, "Items");

		public static class Array extends AbstractMongo.Field {
			public Array() {
			}

			public Array(AbstractMongo.Field parent, String prefix) {
				super(parent, prefix);
			}

			public final String index(Integer i) {
				return field("" + i);
			}
		}
	}
}
